home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5545 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  2.5 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news text default
99% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 72 75 | 75 2e 6e 6c 21 6e 65 77 |Path: ru|u.nl!new|
|00000010| 73 0a 46 72 6f 6d 3a 20 | 45 72 69 6b 20 50 68 69 |s.From: |Erik Phi|
|00000020| 6c 69 70 70 75 73 20 3c | 65 72 69 6b 70 3e 0a 4e |lippus <|erikp>.N|
|00000030| 65 77 73 67 72 6f 75 70 | 73 3a 20 63 6f 6d 70 2e |ewsgroup|s: comp.|
|00000040| 6c 61 6e 67 2e 63 2b 2b | 0a 53 75 62 6a 65 63 74 |lang.c++|.Subject|
|00000050| 3a 20 52 65 3a 20 51 75 | 65 73 74 69 6f 6e 20 3a |: Re: Qu|estion :|
|00000060| 20 6c 69 6e 6b 20 63 2b | 2b 20 63 6f 64 65 20 69 | link c+|+ code i|
|00000070| 6e 74 6f 20 43 20 63 6f | 64 65 0a 44 61 74 65 3a |nto C co|de.Date:|
|00000080| 20 35 20 46 65 62 20 31 | 39 39 36 20 31 36 3a 31 | 5 Feb 1|996 16:1|
|00000090| 30 3a 35 36 20 47 4d 54 | 0a 4f 72 67 61 6e 69 7a |0:56 GMT|.Organiz|
|000000a0| 61 74 69 6f 6e 3a 20 41 | 63 61 64 65 6d 69 63 20 |ation: A|cademic |
|000000b0| 43 6f 6d 70 74 65 72 20 | 43 65 6e 74 72 65 20 55 |Compter |Centre U|
|000000c0| 74 72 65 63 68 74 0a 4d | 65 73 73 61 67 65 2d 49 |trecht.M|essage-I|
|000000d0| 44 3a 20 3c 34 66 35 61 | 36 67 24 6b 30 31 40 6e |D: <4f5a|6g$k01@n|
|000000e0| 69 63 2e 63 63 2e 72 75 | 75 2e 6e 6c 3e 0a 52 65 |ic.cc.ru|u.nl>.Re|
|000000f0| 66 65 72 65 6e 63 65 73 | 3a 20 3c 33 31 31 31 30 |ferences|: <31110|
|00000100| 39 35 30 2e 31 33 36 44 | 40 67 65 6e 65 74 69 71 |950.136D|@genetiq|
|00000110| 75 65 2e 75 76 73 71 2e | 66 72 3e 20 3c 34 66 35 |ue.uvsq.|fr> <4f5|
|00000120| 30 66 39 24 72 73 68 40 | 6c 61 6e 74 61 6e 61 2e |0f9$rsh@|lantana.|
|00000130| 73 69 6e 67 6e 65 74 2e | 63 6f 6d 2e 73 67 3e 0a |singnet.|com.sg>.|
|00000140| 4e 4e 54 50 2d 50 6f 73 | 74 69 6e 67 2d 48 6f 73 |NNTP-Pos|ting-Hos|
|00000150| 74 3a 20 77 73 36 2e 73 | 72 6f 6e 2e 72 75 75 2e |t: ws6.s|ron.ruu.|
|00000160| 6e 6c 0a 4d 69 6d 65 2d | 56 65 72 73 69 6f 6e 3a |nl.Mime-|Version:|
|00000170| 20 31 2e 30 0a 43 6f 6e | 74 65 6e 74 2d 54 79 70 | 1.0.Con|tent-Typ|
|00000180| 65 3a 20 74 65 78 74 2f | 70 6c 61 69 6e 3b 20 63 |e: text/|plain; c|
|00000190| 68 61 72 73 65 74 3d 75 | 73 2d 61 73 63 69 69 0a |harset=u|s-ascii.|
|000001a0| 43 6f 6e 74 65 6e 74 2d | 54 72 61 6e 73 66 65 72 |Content-|Transfer|
|000001b0| 2d 45 6e 63 6f 64 69 6e | 67 3a 20 37 62 69 74 0a |-Encodin|g: 7bit.|
|000001c0| 58 2d 4d 61 69 6c 65 72 | 3a 20 4d 6f 7a 69 6c 6c |X-Mailer|: Mozill|
|000001d0| 61 20 31 2e 31 4e 20 28 | 58 31 31 3b 20 49 3b 20 |a 1.1N (|X11; I; |
|000001e0| 53 75 6e 4f 53 20 34 2e | 31 2e 33 5f 55 31 20 73 |SunOS 4.|1.3_U1 s|
|000001f0| 75 6e 34 63 29 0a 54 6f | 3a 20 74 6f 68 63 73 40 |un4c).To|: tohcs@|
|00000200| 70 6f 62 6f 78 2e 6f 72 | 67 2e 73 67 0a 58 2d 55 |pobox.or|g.sg.X-U|
|00000210| 52 4c 3a 20 6e 65 77 73 | 3a 34 66 35 30 66 39 24 |RL: news|:4f50f9$|
|00000220| 72 73 68 40 6c 61 6e 74 | 61 6e 61 2e 73 69 6e 67 |rsh@lant|ana.sing|
|00000230| 6e 65 74 2e 63 6f 6d 2e | 73 67 0a 0a 49 20 64 6f |net.com.|sg..I do|
|00000240| 6e 27 74 20 74 68 69 6e | 6b 20 69 74 27 73 20 72 |n't thin|k it's r|
|00000250| 65 61 6c 69 73 74 69 63 | 20 74 6f 20 65 78 70 65 |ealistic| to expe|
|00000260| 63 74 20 74 68 65 20 72 | 65 63 6f 6d 70 69 6c 65 |ct the r|ecompile|
|00000270| 20 65 78 69 73 74 69 6e | 67 20 43 2d 63 6f 64 65 | existin|g C-code|
|00000280| 20 77 69 74 68 0a 61 20 | 43 2b 2b 2d 63 6f 6d 70 | with.a |C++-comp|
|00000290| 69 6c 65 72 2e 20 49 6e | 20 6d 6f 73 74 20 63 61 |iler. In| most ca|
|000002a0| 73 65 73 2c 20 43 2d 6c | 69 62 72 61 72 69 65 73 |ses, C-l|ibraries|
|000002b0| 20 77 69 6c 6c 20 62 65 | 20 75 73 65 64 2c 20 77 | will be| used, w|
|000002c0| 68 69 63 68 20 63 61 6e | 6e 6f 74 20 62 65 0a 72 |hich can|not be.r|
|000002d0| 65 63 6f 6d 70 69 6c 65 | 64 2e 20 54 6f 20 73 6f |ecompile|d. To so|
|000002e0| 6c 76 65 20 74 68 69 73 | 20 70 72 6f 62 6c 65 6d |lve this| problem|
|000002f0| 2c 20 6f 6e 65 20 68 61 | 73 20 74 6f 20 6d 61 6b |, one ha|s to mak|
|00000300| 65 20 43 2d 77 72 61 70 | 70 65 72 73 20 66 6f 72 |e C-wrap|pers for|
|00000310| 20 43 2b 2b 2d 0a 66 75 | 6e 63 74 69 6f 6e 73 2e | C++-.fu|nctions.|
|00000320| 0a 0a 53 69 6e 63 65 20 | 66 75 6e 63 74 69 6f 6e |..Since |function|
|00000330| 73 20 63 61 6e 20 62 65 | 20 6f 76 65 72 6c 6f 61 |s can be| overloa|
|00000340| 64 65 64 20 69 6e 20 43 | 2b 2b 2c 20 74 68 65 69 |ded in C|++, thei|
|00000350| 72 20 6e 61 6d 65 73 20 | 61 72 65 20 65 6e 63 6f |r names |are enco|
|00000360| 64 65 64 20 62 79 20 74 | 68 65 20 43 2b 2b 0a 63 |ded by t|he C++.c|
|00000370| 6f 6d 70 69 6c 65 72 2c | 20 77 68 69 63 68 20 6d |ompiler,| which m|
|00000380| 61 6b 65 73 20 69 74 20 | 64 69 66 66 69 63 75 6c |akes it |difficul|
|00000390| 74 20 74 6f 20 72 65 66 | 65 72 65 6e 63 65 20 43 |t to ref|erence C|
|000003a0| 2b 2b 20 66 75 6e 63 74 | 69 6f 6e 73 20 62 79 20 |++ funct|ions by |
|000003b0| 75 73 69 6e 67 20 74 68 | 65 0a 66 75 6e 63 74 69 |using th|e.functi|
|000003c0| 6f 6e 20 6e 61 6d 65 73 | 20 61 73 20 73 68 6f 77 |on names| as show|
|000003d0| 6e 20 69 6e 20 68 65 61 | 64 65 72 2d 66 69 6c 65 |n in hea|der-file|
|000003e0| 73 2e 20 0a 48 65 6e 63 | 65 2c 20 77 69 74 68 69 |s. .Henc|e, withi|
|000003f0| 6e 20 74 68 65 20 43 2d | 70 72 6f 67 72 61 6d 2c |n the C-|program,|
|00000400| 20 77 65 20 6d 75 73 74 | 20 68 61 76 65 20 61 20 | we must| have a |
|00000410| 70 6f 69 6e 74 65 72 20 | 74 6f 20 74 68 65 20 6f |pointer |to the o|
|00000420| 62 6a 65 63 74 20 69 6e | 20 71 75 65 73 74 69 6f |bject in| questio|
|00000430| 6e 2e 0a 0a 53 75 70 70 | 6f 73 65 2c 20 69 6e 20 |n...Supp|ose, in |
|00000440| 43 2b 2b 20 77 65 20 68 | 61 76 65 20 61 6e 20 61 |C++ we h|ave an a|
|00000450| 63 63 65 73 73 20 66 75 | 6e 63 74 69 6f 6e 20 63 |ccess fu|nction c|
|00000460| 61 6c 6c 65 64 20 4d 65 | 73 73 61 67 65 28 29 2c |alled Me|ssage(),|
|00000470| 20 66 6f 72 20 6f 62 6a | 65 63 74 73 20 6f 66 0a | for obj|ects of.|
|00000480| 74 79 70 65 0a 4f 62 6a | 65 63 74 2e 20 49 66 20 |type.Obj|ect. If |
|00000490| 74 68 65 20 76 61 72 69 | 61 62 6c 65 20 70 4f 62 |the vari|able pOb|
|000004a0| 6a 65 63 74 20 69 73 20 | 61 20 70 6f 69 6e 74 65 |ject is |a pointe|
|000004b0| 72 20 74 6f 20 61 6e 20 | 6f 62 6a 65 63 74 20 6f |r to an |object o|
|000004c0| 66 20 74 79 70 65 20 4f | 62 6a 65 63 74 2c 20 77 |f type O|bject, w|
|000004d0| 65 0a 63 61 6e 0a 69 6e | 76 6f 6b 65 20 74 68 65 |e.can.in|voke the|
|000004e0| 20 6d 65 74 68 6f 64 20 | 73 69 6d 70 6c 79 20 62 | method |simply b|
|000004f0| 79 3a 0a 0a 70 4f 62 6a | 65 63 74 2d 3e 4d 65 73 |y:..pObj|ect->Mes|
|00000500| 73 61 67 65 28 29 3b 0a | 0a 53 69 6e 63 65 20 77 |sage();.|.Since w|
|00000510| 65 20 64 6f 6e 27 74 20 | 68 61 76 65 20 70 6f 69 |e don't |have poi|
|00000520| 6e 74 65 72 73 20 74 6f | 20 6f 62 6a 65 63 74 73 |nters to| objects|
|00000530| 20 69 6e 20 43 2c 20 77 | 65 20 64 65 63 6c 61 72 | in C, w|e declar|
|00000540| 65 20 61 20 6e 65 77 20 | 74 79 70 65 20 63 61 6c |e a new |type cal|
|00000550| 6c 65 64 0a 48 61 6e 64 | 6c 65 3a 0a 0a 74 79 70 |led.Hand|le:..typ|
|00000560| 65 64 65 66 20 76 6f 69 | 64 20 2a 48 61 6e 64 6c |edef voi|d *Handl|
|00000570| 65 3b 0a 0a 4e 6f 77 20 | 77 65 20 63 61 6e 20 64 |e;..Now |we can d|
|00000580| 65 66 69 6e 65 20 74 68 | 65 20 66 6f 6c 6c 6f 77 |efine th|e follow|
|00000590| 69 6e 67 20 66 75 6e 63 | 74 69 6f 6e 3a 0a 0a 65 |ing func|tion:..e|
|000005a0| 78 74 65 72 6e 20 22 43 | 22 20 7b 0a 20 20 20 20 |xtern "C|" {. |
|000005b0| 76 6f 69 64 20 4d 65 73 | 73 61 67 65 28 48 61 6e |void Mes|sage(Han|
|000005c0| 64 6c 65 20 73 29 20 7b | 0a 20 20 20 20 20 20 20 |dle s) {|. |
|000005d0| 20 20 28 28 4f 62 6a 65 | 63 74 2a 29 73 29 2d 3e | ((Obje|ct*)s)->|
|000005e0| 4d 65 73 73 61 67 65 28 | 29 3b 0a 7d 0a 0a 49 74 |Message(|);.}..It|
|000005f0| 20 69 73 20 69 6e 76 6f | 6b 65 64 20 61 73 20 66 | is invo|ked as f|
|00000600| 6f 6c 6c 6f 77 73 3a 0a | 0a 48 61 6e 64 6c 65 20 |ollows:.|.Handle |
|00000610| 2a 68 20 20 2f 2a 20 68 | 20 70 6f 69 6e 74 73 20 |*h /* h| points |
|00000620| 74 6f 20 61 6e 20 6f 62 | 6a 65 63 74 20 2a 2f 0a |to an ob|ject */.|
|00000630| 4d 65 73 73 61 67 65 28 | 68 29 3b 0a 0a 54 68 65 |Message(|h);..The|
|00000640| 20 63 6f 6e 73 74 72 75 | 63 74 20 27 65 78 74 65 | constru|ct 'exte|
|00000650| 72 6e 20 22 43 22 20 7b | 20 2e 2e 2e 7d 20 65 6e |rn "C" {| ...} en|
|00000660| 73 75 72 65 73 20 74 68 | 61 74 20 74 68 65 20 66 |sures th|at the f|
|00000670| 75 6e 63 74 69 6f 6e 20 | 6e 61 6d 65 20 69 73 20 |unction |name is |
|00000680| 6e 6f 74 0a 65 6e 63 6f | 64 65 64 20 62 79 20 74 |not.enco|ded by t|
|00000690| 68 65 20 43 2b 2b 20 63 | 6f 6d 70 69 6c 65 72 2e |he C++ c|ompiler.|
|000006a0| 20 41 6c 73 6d 6f 73 74 | 20 61 6e 79 20 6d 65 74 | Alsmost| any met|
|000006b0| 68 6f 64 20 63 61 6e 20 | 62 65 20 68 69 64 64 65 |hod can |be hidde|
|000006c0| 6e 20 74 68 69 73 20 77 | 61 79 0a 61 6e 64 20 63 |n this w|ay.and c|
|000006d0| 61 6c 6c 65 64 20 62 79 | 20 61 20 43 2d 70 72 6f |alled by| a C-pro|
|000006e0| 67 72 61 6d 2e 20 20 0a | 0a 43 6f 6e 73 74 72 75 |gram. .|.Constru|
|000006f0| 63 74 6f 72 73 20 63 61 | 6e 20 62 65 20 63 61 6c |ctors ca|n be cal|
|00000700| 6c 65 64 20 75 73 69 6e | 67 20 74 68 65 20 66 6f |led usin|g the fo|
|00000710| 6c 6c 6f 77 69 6e 67 20 | 77 72 61 70 70 65 72 3a |llowing |wrapper:|
|00000720| 0a 0a 65 78 74 65 72 6e | 20 22 43 22 20 7b 0a 0a |..extern| "C" {..|
|00000730| 20 20 20 48 61 6e 64 6c | 65 20 4e 65 77 4f 62 6a | Handl|e NewObj|
|00000740| 65 63 74 28 69 6e 74 20 | 61 72 67 31 29 20 7b 0a |ect(int |arg1) {.|
|00000750| 09 4f 62 6a 65 63 74 20 | 2a 70 4f 62 6a 65 63 74 |.Object |*pObject|
|00000760| 20 3d 20 6e 65 77 20 4f | 62 6a 65 63 74 28 61 72 | = new O|bject(ar|
|00000770| 67 31 29 3b 0a 09 72 65 | 74 75 72 6e 20 28 48 61 |g1);..re|turn (Ha|
|00000780| 6e 64 6c 65 29 70 4f 62 | 6a 65 63 74 3b 0a 20 20 |ndle)pOb|ject;. |
|00000790| 20 7d 0a 7d 0a 0a 54 6f | 20 75 73 65 20 74 68 69 | }.}..To| use thi|
|000007a0| 73 20 66 75 6e 63 74 69 | 6f 6e 20 69 6e 20 61 20 |s functi|on in a |
|000007b0| 43 2d 70 72 6f 67 72 61 | 6d 3a 0a 0a 48 61 6e 64 |C-progra|m:..Hand|
|000007c0| 6c 65 20 68 3b 0a 68 20 | 3d 20 4e 65 77 4f 62 6a |le h;.h |= NewObj|
|000007d0| 65 63 74 28 6d 79 41 72 | 67 29 3b 0a 0a 4f 76 65 |ect(myAr|g);..Ove|
|000007e0| 72 6c 6f 61 64 65 64 20 | 6f 70 65 72 61 74 6f 72 |rloaded |operator|
|000007f0| 73 20 63 61 6e 20 62 65 | 20 69 6e 76 6f 6b 65 64 |s can be| invoked|
|00000800| 20 75 73 69 6e 67 20 74 | 68 65 20 73 61 6d 65 20 | using t|he same |
|00000810| 74 65 63 68 6e 69 71 75 | 65 2e 0a 0a 45 72 69 6b |techniqu|e...Erik|
|00000820| 20 50 68 69 6c 69 70 70 | 75 73 0a 0a 2d 2d 2d 2d | Philipp|us..----|
|00000830| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000840| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2b 2d 2d 2d 2d |--------|---+----|
|00000850| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000860| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000870| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2b 0a 7c 20 45 72 |--------|--+.| Er|
|00000880| 69 6b 20 50 68 69 6c 69 | 70 70 75 73 09 09 7c 20 |ik Phili|ppus..| |
|00000890| 53 52 4f 4e 09 09 09 09 | 20 20 20 20 20 20 20 20 |SRON....| |
|000008a0| 20 20 20 20 20 20 20 7c | 0a 7c 09 09 09 09 7c 09 | ||.|....|.|
|000008b0| 09 09 09 09 20 20 20 20 | 20 20 20 7c 0a 7c 20 65 |.... | |.| e|
|000008c0| 72 69 6b 70 40 72 75 6c | 72 6f 6c 2e 55 6e 69 76 |rikp@rul|rol.Univ|
|000008d0| 4c 65 69 64 65 6e 2e 6e | 6c 09 7c 20 4c 61 62 6f |Leiden.n|l.| Labo|
|000008e0| 72 61 74 6f 72 79 20 66 | 6f 72 20 53 70 61 63 65 |ratory f|or Space|
|000008f0| 20 52 65 73 65 61 72 63 | 68 09 09 20 20 20 20 20 | Researc|h.. |
|00000900| 20 20 7c 0a 7c 20 74 65 | 6c 2e 20 30 39 31 2d 37 | |.| te|l. 091-7|
|00000910| 31 2d 32 37 35 38 30 35 | 09 09 7c 20 4e 69 65 6c |1-275805|..| Niel|
|00000920| 73 20 42 6f 68 72 77 65 | 67 20 32 09 09 09 20 20 |s Bohrwe|g 2... |
|00000930| 20 20 20 20 20 7c 0a 7c | 20 66 61 78 3a 20 30 39 | |.|| fax: 09|
|00000940| 31 2d 37 31 2d 32 37 35 | 38 31 39 09 09 7c 20 32 |1-71-275|819..| 2|
|00000950| 33 33 33 20 43 41 20 4c | 65 69 64 65 6e 09 09 09 |333 CA L|eiden...|
|00000960| 20 20 20 20 20 20 20 7c | 0a 7c 20 09 09 09 09 7c | ||.| ....||
|00000970| 20 74 68 65 20 4e 65 74 | 68 65 72 6c 61 6e 64 73 | the Net|herlands|
|00000980| 09 09 09 20 20 20 20 20 | 20 20 7c 09 09 09 2b 2d |... | |...+-|
|00000990| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000009a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2b 2d |--------|------+-|
|000009b0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000009c0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000009d0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2b 0a 0a |--------|-----+..|
+--------+-------------------------+-------------------------+--------+--------+